home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / glibc-1.09 / glibc-1 / glibc-1.09.1 / Make-dist < prev    next >
Encoding:
Text File  |  1994-11-01  |  6.8 KB  |  219 lines

  1. # Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  2. # This file is part of the GNU C Library.
  3.  
  4. # The GNU C Library is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Library General Public License as
  6. # published by the Free Software Foundation; either version 2 of the
  7. # License, or (at your option) any later version.
  8.  
  9. # The GNU C Library is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. # Library General Public License for more details.
  13.  
  14. # You should have received a copy of the GNU Library General Public
  15. # License along with the GNU C Library; see the file COPYING.LIB.  If
  16. # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. # Cambridge, MA 02139, USA.
  18.  
  19. dist:
  20.  
  21. ifdef subdir
  22. .. := ../
  23. else
  24. .. :=
  25. endif
  26.  
  27. include $(..)Makeconfig
  28.  
  29. foo:=$(shell echo 'distribute=$(distribute)'>&2)
  30. foo:=$(shell echo 'foobar=$(filter %.c %.S %.s %.h,$(distribute))'>&2)
  31.  
  32. ifndef sysdep_dirs
  33. # Find all sysdep directories.
  34. export sysdep_dirs := $(shell find $(..)sysdeps -type d ! -name RCS -print)
  35. else
  36. # Defined by the parent.
  37. sysdep_dirs := $(addprefix $(..),$(sysdep_dirs))
  38. endif
  39.  
  40. sysdep-Subdir-files := $(wildcard $(addsuffix /Subdirs,$(sysdep_dirs)))
  41. ifdef sysdep-Subdir-files
  42. subdirs := $(sort $(subdirs) \
  43.           $(shell sed -e 's/\#.*$$//' $(sysdep-Subdir-files)))
  44. endif
  45.  
  46.  
  47. # Makefiles can define `source_dirs' to list nonstandard directories
  48. # where source files might be found.
  49.  
  50. ifdef    subdir
  51. all-headers = $(headers)
  52. else
  53. +distinfo := $(shell MAKEFLAGS= MFLAGS= $(MAKE) -s no_deps=t \
  54.              inhibit_interface_rules=t inhibit_mach_syscalls=t \
  55.              subdirs='$(subdirs)' echo-distinfo | grep -v '^make')
  56. foo:=$(shell echo>&2 '+distinfo=$(+distinfo)')
  57. all-headers := $(patsubst +header+%,%,$(filter +header+%,$(+distinfo)))
  58. # Ignore subdir headers without top-level indirections.
  59. all-headers := $(sort $(headers) $(wildcard $(all-headers)))
  60. +subdir-nodist := $(patsubst +nodist+%,%,$(filter +nodist+%,$(+distinfo)))
  61. +subdir-headers := $(filter-out $(headers),$(all-headers))
  62. endif
  63. foo:=$(shell echo 'IS THIS WORKING??? all-headers=$(all-headers)' >&2)
  64.  
  65. # Find all sysdep sources and headers.
  66. +maybe-sysdeps := $(sources) $(sources:.c=.s) $(sources:.c=.S) $(all-headers) \
  67.           $(filter %.c %.S %.s %.h %.sub,$(distribute))
  68. foo:=$(shell echo '+maybe-sysdeps=$(+maybe-sysdeps)'>&2)
  69. # Find all the files that have a stub or generic version.
  70. try-sysdeps := $(foreach dir,$(..)sysdeps/stub $(..)sysdeps/generic,\
  71.                  $(addprefix $(dir)/,$(+maybe-sysdeps)))
  72. foo:=$(shell echo 'try-sysdeps=$(try-sysdeps)'>&2)
  73. +sysdeps := $(wildcard $(try-sysdeps))
  74. foo:=$(shell echo 'stub/generic +sysdeps=$(+sysdeps)'>&2)
  75. +sysdep-names := $(sort $(notdir $(+sysdeps)))
  76. foo:=$(shell echo '+sysdep-names=$(+sysdep-names)' >&2)
  77.  
  78. # Now find all the sysdep versions of those files.
  79. +sysdeps := $(wildcard $(foreach dir,$(sysdep_dirs) $(source_dirs),\
  80.                  $(addprefix $(dir)/, \
  81.                          $(+sysdep-names) \
  82.                          $(+sysdep-names:.c=.s) \
  83.                          $(+sysdep-names:.c=.S) \
  84.                   )))
  85.  
  86.  
  87. # Source and header files to go in the distribution tar file.
  88.  
  89. .S.s := $(wildcard $(sources:.c=.S) $(sources:.c=.s))
  90. sources := $(filter-out $(addsuffix .c,$(basename $(.S.s))),$(sources)) $(.S.s)
  91.  
  92. +out := $(patsubst %.S,%.c,$(+sysdep-names:.s=.c)) \
  93.     $(addsuffix .c,$(sysdep_routines)) \
  94.     $(+subdir-nodist)
  95. #foo:=$(shell echo '+out=$(+out)' >&2; echo foofoo >&2)
  96. +tsrcs    := $(filter-out $(+out) $(addprefix %/,$(+out)), \
  97.             $(sources) $(all-headers) $(distribute)) \
  98.        $(+sysdeps)
  99. foo:=$(shell echo made +tsrcs >&2)
  100. foo:=$(shell echo generated='$(generated)' >&2)
  101. generated := $(sort $(generated) $(generated:.S=.c) $(generated:.s=.c))
  102. foo:=$(shell echo now generated='$(generated)' >&2)
  103. +tsrcs := $(sort $(filter-out $(generated),$(+tsrcs)))
  104. foo:=$(shell echo '+tsrcs=$(+tsrcs)'>&2)
  105. foo:=$(shell echo foobie, dammit! >&2)
  106.  
  107. ifndef tardir
  108. rel+vers := $(shell sed -n -e 's/^.*libc_release.*\"\([^"]*\)";$$/\1/p' \
  109.                -e 's/^.*libc_version.*\"\([^"]*\)";$$/\1/p' \
  110.             < $(..)version.c)
  111. release := $(word 1,$(rel+vers))
  112. version := $(word 2,$(rel+vers))
  113. export tardir := glibc-$(version)
  114. endif
  115.  
  116. $(..)glibc-$(version):
  117.     ln -s . $@
  118.  
  119. +tsrcs := $(+tsrcs) \
  120.       TAGS
  121. .PHONY: TAGS
  122. TAGS: $(..)MakeTAGS
  123.     $(MAKE) -f $< $@ -o subdir_TAGS
  124.  
  125. ifdef       subdir
  126.  
  127. foo:=$(shell echo subdir foo >&2)
  128.  
  129. +tsrcs := Makefile $(+tsrcs)                \
  130.       $(addsuffix .c,$(others) $(tests))        \
  131.       $(wildcard $(addsuffix .input,$(tests))    \
  132.       $(addsuffix .args,$(tests)))
  133. +tardeps := $(strip $(+tsrcs))
  134. +tsrcs := $(addprefix $(tardir)/$(subdir)/,$(+tardeps))
  135.  
  136. verbose = v
  137.  
  138. .PHONY: dist
  139. dist: $(..)$(tardir) $(+tardeps)
  140.     @cd ..; if test -f dist.tar; then c=u; else c=c; fi;    \
  141.     $(+cmdecho) "cd ..; tar $${c}h$(verbose)f dist.tar ...";    \
  142.     tar $${c}h$(verbose)f dist.tar $(+tsrcs)
  143.  
  144. else    # Parent makefile.
  145.  
  146. # Find what other things sysdep directories want to distribute.
  147.  
  148. foo:=$(shell echo parent foobie>&2)
  149. +sysdep-distfiles := $(wildcard $(addsuffix /Dist,$(sysdep_dirs)))
  150. foo:=$(shell echo +sysdep-distfiles='$(+sysdep-distfiles)'>&2)
  151. +sysdep-dist := $(foreach file,$(+sysdep-distfiles),\
  152.               $(addprefix $(dir $(file)), \
  153.                       $(shell sed -e 's/\#.*$$//' $(file)))) \
  154.         $(+sysdep-distfiles) \
  155.         $(sysdep-Subdir-files)
  156. foo:=$(shell echo '+sysdep-dist=$(+sysdep-dist)' >&2)
  157.  
  158. subdirs := $(filter-out crypt,$(subdirs))
  159.  
  160. +sysdep-tsrcs := $(wildcard $(foreach file,Makefile Implies \
  161.                            configure configure.in,\
  162.                       $(addsuffix /$(file),$(sysdep_dirs)))) \
  163.          $(+sysdep-dist)
  164.  
  165. +tsrcs := $(+tsrcs) $(+sysdep-tsrcs)
  166.  
  167. %/configure: %/configure.in
  168.     autoconf $(ACFLAGS) $< > $@.new
  169.     mv -f $@.new $@
  170.  
  171. .PHONY: dist
  172. dist: $(tardir).tar.gz $(tardir)-crypt.tar.gz
  173.  
  174. $(tardir)-crypt.tar.gz: crypt/crypt.tar.gz
  175.     ln $< $@
  176. crypt/%: FORCE
  177.     $(MAKE) -C $(@D) $(@F)
  178. FORCE:
  179.  
  180. subdir_dist: dist.tar
  181. dist.tar: $(tardir) $(+tsrcs)
  182.     tar chvf $@ $(addprefix $(tardir)/,$(filter-out $(tardir),$^))
  183.  
  184. $(tardir).tar: dist.tar subdir_dist
  185.     tar xfv $< -C /tmp | doschk
  186.     tar covf $@ -C /tmp $(tardir)
  187.     -rm -fr /tmp/$(tardir) &
  188.  
  189. %.Z: %
  190.     compress -c $< > $@
  191.  
  192. %.gz: %
  193.     gzip -9 -v -c $< > $@
  194.  
  195. foo:=$(shell echo subdirs=$(subdirs) >&2)
  196. dist-subdirs := $(addprefix dist-,$(subdirs)) # dist-manual
  197. .PHONY: subdir_dist $(dist-subdirs)
  198. subdir_dist: $(dist-subdirs)
  199. $(dist-subdirs):
  200.     $(MAKE) -C $(patsubst dist-%,%,$@) dist
  201.  
  202. # This is here instead of in Makefile so it can use $(release) and $(version).
  203. README: README.template version.c
  204.     -rm -f $@
  205.     sed -e 's/RELEASE/$(release)/' -e 's/VERSION/$(version)/' < $< > $@
  206. # Make it unwritable so I won't change it by mistake.
  207.     chmod 444 $@
  208.  
  209.  
  210. endif    # Subdirectory vs. parent makefile
  211.  
  212. # Get these things out of the environment because they take up lots of space.
  213. unexport distribute generated
  214.  
  215. # Fnord.
  216. export inhibit_mach_syscalls=t
  217. export no_deps=t
  218. export inhibit_interface_rules=t
  219.